<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var z=/^([0-9A-Za-z\u4e00-\u9fa5]+,)*[0-9A-Za-z\u4e00-\u9fa5]+$/;
        function f() {
            var zfcval = document.getElementById("zfc").value;
            var czval = document.getElementById("cz").value;
            if (z.test(zfcval)){
                var strings = zfcval.split(",");
                for (var i=0;i<strings.length;i++){
                    if (czval==strings[i]){
                        alert(czval+"在数组["+zfcval+"]的索引位置是"+i);
                        break;
                    } else if (i==strings.length-1){
                        alert("要查找的元素不存在! ! !")
                    }
                }
            } else {
                alert("字符串数组格式错误,请重新输入! ! !")
            }
        }
    </script>
</head>
<body>
字符串数组格式:(a,哈哈,3):
<input id="zfc" type="text"/>
要查找的元素:
<input id="cz" type="text"/>
<input type="button" value="开始查找" onclick="f()"/>
</body>
</html>